package com.vito.oa.act.event.service.impl;

import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;

import com.alibaba.dubbo.config.annotation.Service;
import com.vito.oa.act.event.service.EventPublisherService;

@Service
public class ActivitiEventPublisherAwareService implements EventPublisherService, ApplicationEventPublisherAware {

	private ApplicationEventPublisher publisher = null;
	@Override
	public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
		this.publisher = applicationEventPublisher;
	}
	
	@Override
	public boolean sendMessage(ApplicationEvent event){
		if(null == publisher){
			return false;
		}
		publisher.publishEvent(event);
		return true;
	}

}
